<%--
  Created by IntelliJ IDEA.
  User: 10269
  Date: 2021/2/20
  Time: 16:47
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>用户注册</title>

</head>
<body>
<form id="registerForm">
    <p><label>username:<input id="username" name="username"></label></p>
    <p><label>password:<input id="password" name="password"></label></p>
    <p><label>phone:<input id="phone" name="phone"></label></p>
    <p> <input type="button" id="btn" value="register"> </p>
</form>
</body>
<script src="${pageContext.request.contextPath}/js/jquery-3.4.1.min.js"></script>
<script>

    $("#btn").click(function () {
        const data = {
            id:null,
            username: $("#username").val(),
            password: $("#password").val(),
            phone: $("#phone").val(),
            createTime:null
        };

        $.ajax({
            type: 'POST',
            url: "${pageContext.request.contextPath}/register",
            data: JSON.stringify(data),
            success: function (result) {
                console.log(result);
                history.back();
            },
            dataType: 'JSON',
            contentType: "application/json;charset=UTF-8"
        });
    });


</script>
</html>
